﻿using Anke.SHManage.BLL;
using Anke.SHManage.MSSQLDAL.TJDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class Bonus_YiShengWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();
        }

        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-21 07:30:00"); //查询起始时间默认为上个月21号 07:30
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-21 07:30:00"); //查询截止时间默认为本月21号 07:30
            BindReportDataSource();
        }

        protected void BindReportDataSource()
        {
            DateTime beginTime = Convert.ToDateTime(this.StartDate.Text);
            DateTime endTime = Convert.ToDateTime(this.EndDate.Text);
            string doctor = Convert.ToString(this.Doctor.Text);

            string start1 = beginTime.ToString("yyyy/MM/dd HH:mm:ss");
            string end1 = endTime.ToString("yyyy/MM/dd HH:mm:ss");

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/Bonus_YiSheng.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("startTime", start1);
            Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("endTime", end1);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed });
            string eventDispatchCenterID = UserOperateContext.Current.Seesion_Dispatch_SubCenterID; //2020-11-22 zch 登录人所处急救中心
            TJDAL dalt = new TJDAL();
            this.Page.Title = "随车医生按完成岗位实绩结算表";
            DataTable dt = dalt.Get_TJ_Bonus_YiSheng(beginTime, endTime, doctor, eventDispatchCenterID);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));
            this.ReportViewer1.LocalReport.Refresh();
        }
    }
}